package com.reshare.config;

import com.reshare.interceptors.NoLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class MvcConfig implements WebMvcConfigurer{


    /**
     * 拦截器的配置
     *
     * @return
     */
    @Autowired
    private NoLoginInterceptor noLoginInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //指定拦截器对象
        registry.addInterceptor(noLoginInterceptor)
                //拦截路径
                .addPathPatterns("/**")
                //放行路径
                .excludePathPatterns("/index","/user/toRegister", "/user/login", "/js/**", "/css/**", "/images/**", "/lib/**");
    }

}
